package com.reggie.module.entity.dto.employeeDto;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.reggie.module.entity.po.Employee;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.DigestUtils;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;

import static com.reggie.common.Constant.LOGIN_SESSION;

/**
 * @Author 早睡蛋
 * @Date 2022/9/20 14:11:59
 * @Desc:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ChangeStatusDto {

    @ApiModelProperty(value = "id", required = true)
    @TableId("id")
    @NotNull(message = "id不能为空")
    private Long id;

    @ApiModelProperty(value = "状态", required = true)
    @TableId("status")
    @NotEmpty(message = "状态不能为空")
    @Pattern(regexp = "(^[0-1]*$)", message = "状态：0或者1")
    private String status;

    private LocalDateTime updateTime;

    private Long updateUser;


    public ChangeStatusDto(Long id, String status, HttpServletRequest request) {
        this.id = id;
        this.status = status;
        this.updateTime = LocalDateTime.now();
        this.updateUser = (Long) request.getSession().getAttribute(LOGIN_SESSION);
    }

}
